<div class="loginBoard" ng-controller="userLogin">
    <form name="loginForm" ng-submit="processLoginForm(loginForm.$valid)" novalidate>
        <h3>用户登录 &nbsp;<small class="text-danger hide" id="errorInfo">邮箱和密码不匹配</small></h3>
        <div class="form-group">
            <input type="email" class="form-control" name="email" ng-model="logFormData.email" ng-pattern="/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/" placeholder="请填写邮箱"  required>
            <label ng-cloak for="inputError" class="control-label text-danger" ng-show="loginForm.email.$invalid && !loginForm.email.$pristine"><i class="glyphicon glyphicon-info-sign"></i> 请填写正确的邮箱地址</label>
        </div>
        <div class="form-group">
            <input type="password" class="form-control" name="password" ng-model="logFormData.password" ng-pattern="/(?!^\\d+$)(?!^[a-zA-Z]+$)(?!^[_#@]+$).{5,}/" ng-maxlength="12" placeholder="请输入密码" required>
            <label ng-cloak for="inputError" class="control-label text-danger" ng-show="loginForm.password.$invalid && !loginForm.password.$pristine"><i class="glyphicon glyphicon-info-sign"></i> 6-12位，只能包含字母、数字和下划线</label>
        </div>
        <div id="ul-s5">
            <button type="submit" class="btn btn-default" ng-disabled="loginForm.$invalid">登录</button>&nbsp;
            <small><a href="/users/lostPassword">忘记密码？</a></small>
        </div>
    </form>
</div>
<script>
    var webApp = angular.module('webApp',[]);
    webApp.controller('userLogin',function($scope,$http){
        $scope.processLoginForm = function(isVaild){
            if(isVaild){
                //成功
                $http({
                    method:'POST',
                    url:'/users/doLogin',
                    data: $.param($scope.logFormData),
                    headers:{'Content-type':'application/x-www-form-urlencoded'}
                }).success(function(data){
                    if(data === 'success'){
                        alert('登录成功');
                        window.location = '/';
                    }else{
                        $('#errorInfo').removeClass('hide').text(data);
                    }
                })
            }else{
                alert('error');
            }
        }
    })
</script>